Skip to content

Conversation

@nikita-savelyevv
Copy link
Collaborator

@nikita-savelyevv nikita-savelyevv commented Oct 31, 2025

Changes

Added nncf.Dataset.RESET_STATE_KEY constant to specify when to reset model state. This constant is used by OpenVINO backend to control resetting of internal model state between model inferences. This key can be added to a dataset sample input dictionary with either True or False value. With True value, the model state will be reset before inference on the corresponding sample, and with False the state will not be reset.

For an example of usage please see huggingface/optimum-intel#1505.

Reason for changes

Without this logic static quantization quality of stateful Whisper models is poor because a state of a stateful model must be cleared with the same schedule as it is done during calibration input data collection.

Related tickets

172705

Tests

Added tests/openvino/native/test_engine.py::test_stateful_model_inference_with_controlled_resetting.

@nikita-savelyevv nikita-savelyevv requested a review from a team as a code owner October 31, 2025 13:00
@nikita-savelyevv
Copy link
Collaborator Author

Example usage: huggingface/optimum-intel#1505

@github-actions github-actions bot added the NNCF OpenVINO Pull requests that updates NNCF OpenVINO label Oct 31, 2025
@nikita-savelyevv nikita-savelyevv changed the title [OpenVINO] Add API for resetting state of stateful OV models [OpenVINO] Introduce a way to control resetting of the state of stateful OV models Oct 31, 2025
@nikita-savelyevv nikita-savelyevv force-pushed the ns/stateful-models-quantization branch from db81db1 to 5f7518b Compare November 14, 2025 13:04
@nikita-savelyevv nikita-savelyevv marked this pull request as draft November 14, 2025 13:05
@github-actions github-actions bot added the API Public API-impacting changes label Nov 14, 2025
@github-actions github-actions bot removed the API Public API-impacting changes label Nov 27, 2025
@nikita-savelyevv nikita-savelyevv marked this pull request as ready for review November 27, 2025 12:41
# between model inferences. This key can be added to a dataset sample input dictionary with either
# `True` or `False` value. With `True` value, the model state will be reset before inference on the corresponding
# sample, and with `False` the state will not be reset.
RESET_STATE_KEY = "nncf_reset_state"
Copy link
Collaborator

@AlexanderDokuchaev AlexanderDokuchaev Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like incorrect place for definition of variable.
May be better define it in src/nncf/definitions.py ?
And for users add note in docstring of Dataset that it can be use stateful models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NNCF OpenVINO Pull requests that updates NNCF OpenVINO

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants